This week’s assignment will encompass the following concepts covered in Class 5 lecture & lab:
Specific Techniques and Tools covered this week will include:
Raster Properties:
The Raster Calculator:
Raster Calculator
Raster Zonal Tools
Raster Report
Raster Terrain Tools
Tasks:
This week’s readings will include 2 sections from the Essentials of Geographic Information Systems textbook; further, 1 supplemental technical readings the raster format within QGIS.
The class 5 quiz will cover only content from the Essentials of Geographic Information Systems textbook as follows:
Chapter 6 - Data Models for GIS
Chapter 7, Section 3 - Spatial Analysis of Raster Data - Surface Analysis
Supplemental readings:
In this assignment two (2) map products will be developed - first a thematic map based on gridded (raster) data for global scale population; and second, a topographic mapping based on DEM input data. Both maps incorporate typical raster processing steps integral to early stages of raster analysis.
Map I:
review the introduction to Gridded Population of the World (GPW), v4 raster data, below:
Gridded Population of the World (GPW), v4 Introduction:
Next gain Nasa Earthdata access and download the raster product:
NASA EarthDATA Login Access
GPW Download
Note: make selection of product as seen in above image.
Alternative Download (In case GADM is not available):
As of this writing, GADM is not available. If that is the case when conducting this assignment, the admin levels per many countries can also be accessed at Humanitarian Data Exchange. Here subnational can operate as the search term, returning many countries across admin 0, admin 1, admin 2 and admin 3 geographies:
- For instance, for Zimbabwe, OCHA produces a dataset containing all 3 admin levels, as it does for many other countries. Choose the
zipped shapefile or zipped geodatabase option (both lead to the same page):
HDX Interface
HDX Interface
.gdb to QGIS:HDX Interface
admin 0, admin 1, admin 2 and admin 3 geographies. Both admin 0 and admin 2 are necessary for the assignment below: - Run the raster clipping procedure utilizing
admin 0 for your country of choice. This process was demonstrated in the synchronous lecture in a slightly different manner, but same result - vector feature clipping by mask a raster layer:
HDX Interface
Warning: if you receive an invalid polygon error at this juncture, proceed to the section at the bottom of this assignment page titled:
Warning - Invalid Geometries in QGIS (workaround Map 1 as needed)
Remove the global GPW V4 world pop raster from the layers panel and save the project. Open admin 2 layer from the .gdb if you have not done so yet. You should have 3 files at this juncture - the clipped population raster, the country boundary (admin 0) and the subnational boundaries (admin 2):
QGIS - ADMIN Layers + GPW data
Export the admin 2 as a .shp into a project folder you set up for this project. If you do not do this step, you will only be allowed to create virtual fields as the feature will still be inside the .gdb structure.
Next, Run Zonal Statistics for the cell value sum per administrative unit. Here the raster cells contain a count of persons per square kilometer. Each of those cells are then summed by Zonal Statistics to the unique geographies of each admin 2 polygon. Access the tool from Processing Toolbox using the search term zonal:
Zonal Stats
admin 2 feature:Zonal Parameters
Zonal Results - Sum of Raster Values
$area formula in the Field Calculator tool. In order to gain square kilometers, use the following formula in a new field sq.km:Field Calculator
Formula: $area /1000000
Next, calculate population density (pop.den) within each administrative unit using the following formula. Make sure to set the output field type as integer (people are represented by whole numbers):
Field Calculator
pop.den field:Field Calculator - Result
Finalize the map product as a thematic map per admin units for population. Use map and legend titling similar to the following:
Residents per square kilometer within Zimbabwe Provinces
Note: in the expression above people are named ‘residents’; the unit of measurement is set to
per sq. km; and the admin 2 geographies are explicitly named.
Utilize skills from class 4 classification methods to choose the best method for your geography. You will want to find a method that best shows the pattern of the data from dense urban administrative units - which tend to be much smaller - to larger rural units.
See the map example below to guide your map layout choices. Include a classified choropleth map; corresponding legend, map data source tag and title. Research your country of choice to determine the naming convention for second level administrative units. In the case of Zimbabwe, they are known as districts:
Map Design Example
Map II:
In this second map, the raster input will be DEM - Digital Elevation Model for wilderness location where a plant species needs both a suitable slope and direction (aspect). When both factors come together, suitability is increased and given a high value. Both slope and aspect can be derived from DEM inputs, which will be done in this second map. The location is the Sandia Mountains on the east side of Albuquerque, New Mexico. To situate this large scale geography, a inset map will be included in the final map layout for the state of New Mexico. To preview, note below the location of the study area within the New Mexico boundary; the attribute name that can be used in the inset map, and a link to a download location for the New Mexico state boundary:
Input DEM situated within New Mexico State
Note: utilize
NAME00for labeling purposes in the final layout map for the map inset. Alternatively, use a text box item from the layout canvas.
Attribute Table View for New Mexico State
NM State Boundary
To start, access/download the assignment PDF and necessary data:
Assignment 5, Map II PDF + Data:
Utilize Exercise 7 - Raster Data Analysis - Working with Topographic Data, to deliver Map II of assignment 5. The following steps overview does not go into as much detail as does the assignment PDF. However, a map inset and custom legend will be created beyond the processing result detailed in the assignment PDF.
The data needed for this second map is located as follows:
Load assignment raster data into QGIS:
DEM Loaded to QGIS
Raster terrain analysis:Processing Toolbox
Hillshade Parameters
Hillshade Output
Symbolized DEM
Hillshade Properties Dialog
Result
35106-B4 DEM, not the hillshade:Slope Result
35106-B4 DEM, not the hillshade or the slope:Aspect Result
Reclassify by Table
Reclassify by Table - Input
75.480842590332; however, when run on 3.10 QGIS, a maximum value was found as 76.8519. As a result, the following table has been utilized instead of that suggested by the PDF text. Here the value of 77 is inclusive of the maxiumum value of 76.8519 which will reclass all significant slope values between 55 and the max as 3 :Fixed Table - Values Populated
slopeRC. The result may include a zero 0 value; simply delete that value from unique values as it will not be included in the suitability calculation. Symbolize as follows:Rendering
slopeRC. Note that you will copy this layer style for the aspect reclass:Visual Result
Save the slope reclass, save the project.
Next, reclass by table, but this time with Aspect as input. Populate the table per book example:
Reclass by Table - Aspect
Aspect Layer Symbolized
Raster Calculator
Note: names in the raster calculator above are different than those suggested in the book example. Keep in mind the calculation is as follows:
Slope Reclassification + Aspect Reclassification
PlantHabitat.tif results, and symbolize as noted in the PDF for values 2-6. Values increasing from 2 through 6 is the range of suitability where 2 is minimum suitable and 6 is highly suitable.Plant Habitat Visual Results
Map I and Map II will be delivered to Canvas Assignment 5 upload location as two separate map submissions. Design Map I to include a thematic legend appropriate to the country of choice and its population density pattern (Natural Breaks, Quantile, Equal Interval, ect - your choice). .PDF format submission unless the file size is too large to upload; as alternative, choose .jpg, .png or .TIFF format.
Design Map II to include the plant habitat result atop the hillshade raster base. Design a map layout in portrait orientation (right-click inside layout canvas to change paper size and orientation). Utilize the map example to guide your overall design process. Note that this map will feature a custom gradient color ramp for the legend. Utilize the following video guide to develop this additional legend item. Also utilize the New Mexico boundary file to create a titled inset map for the map layout. Export the submission as .TIFF format.
Gradient color ramps:
Note: for the data source tag, utilize the metadata from the original source for the DEM located HERE
Map II Layout Example
QGIS Error Report for Invalid Polygon
Note: Cutline polygon is invalid + point array must contain 0 or >1 elements.
One way to repair geometry problems is to simply create a new version of the dataset using a buffering process set to a zero distance. This BLOG POST covers this workaround.
However, this process above doesn’t always work, and may not work for this assignment where the offending islands will still be offending in the buffer feature. In this case, a Vector > Raster conversion can be conducted, resulting in a raster layer that can be used as a ‘mask’ when the task is to mask a raster with a vector project area. Here you replace the vector mask with a raster mask utilizing the Raster Calculator.
Step 1:
Vector Overlay to Raster Representation
Note: above note the yellow polygons are multiple when overlaid to the population raster. This is a multi-part feature, and some of the features are very small.
Step 2:
Convert the country vector to a raster feature. As you do this the input parameters have to be correct as follows:
Rasterize the Vector
Input tool parameters as follows:
Rasterize Parameters
1 for the country, and no data for everything outside the country.Boolean Raster Result for Mask
Next, open the Raster Calculator. Given that we have a raster of global population, we can overlay that to the new OUTPUTand utilize multiplication. Where 1 exists in the OUTPUT layer, the calculation will result in valid values; everywhere else as no data, outside the frame of analysis:
"OUTPUT@1" * "gpw_v4_population_count_adjusted_to_2015_unwpp_country_totals_rev11_2020_30_sec@1"
Save the GeoTIFF as 'country_name'_pop
Raster Calculator
Step 3:
We can check the results to make sure the new 'country_name'_pop has the same values as the "gpw_v4_population_count_adjusted_to_2015_unwpp_country_totals_rev11_2020_30_sec@1" original layer.
First, under symbolization, each layer has to be set to actual values not estimated values.
Set to Actual Values
Value Tool - Validating Workaround Results